package main.AnalysisJson;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;


public class JsonText {
    public static void main(String[] args) {
        StringBuilder json = new StringBuilder();
        try (BufferedReader br = new BufferedReader(new FileReader("D:\\code\\json-parsing-data\\src\\main\\AnalysisJson\\jsontxte.txt"))) {
            String line;
            while ((line = br.readLine()) != null) {
               json.append(line);
            }
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
        JSONObject jsonObject = JSONObject.parseObject(json.toString());
        String data = jsonObject.getObject("datas", String.class);
        JSONArray objects = JSONObject.parseArray(data);
        int a = 0;
        for (Object object : objects) {

            String fieldName = JSONObject.parseObject(object.toString()).getString("fieldName");
            String fieldstone = JSONObject.parseObject(object.toString()).getString("fieldlabelspan");
            String substring = fieldstone.substring(fieldstone.indexOf(">")+1); // 切分“>”之后的数据
            substring = substring.substring(0,substring.indexOf("<")); // 切分“<”字符串之前的数据
            System.out.println(fieldName + "\t"+ substring);

            a++;
        }
        System.out.println(a);

    }
}
